From 93f0a700fb8520a93b4205a42ca021e428ab38e0 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Tue, 31 Jul 2018 01:48:03 +0200 Subject: [PATCH 01/41] WIP - Prepare RecordTransactionActivity rework - Lock Touch ID if not supported/not configured - Prepare API storage rework - Fix CurrencyTickerList and CurrencyDetailsList crash - --- .../HomeActivityFragments/Summary.java | 5 +- .../Activities/RecordTransactionActivity.java | 24 ++-- .../moodl/Activities/SettingsActivity.java | 117 +++++++++++------- .../moodl/DataManagers/BalanceManager.java | 16 +-- .../CurrencyData/CurrencyDetailsList.java | 5 + .../CurrencyData/CurrencyTickerList.java | 5 + .../moodl/DataManagers/DatabaseManager.java | 110 ++++++++++++++-- .../DataManagers/PreferencesManager.java | 20 +-- .../layout/activity_record_transaction.xml | 19 ++- app/src/main/res/menu/menu_record_action.xml | 10 +- 10 files changed, 228 insertions(+), 103 deletions(-) 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 cf8f721..4083388 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 @@ -40,6 +40,7 @@ import com.daasuu.ei.Ease; import com.daasuu.ei.EasingInterpolator; import com.herbron.moodl.Activities.CurrencySelectionActivity; import com.herbron.moodl.Activities.HomeActivity; +import com.herbron.moodl.Activities.RecordTransactionActivity; import com.herbron.moodl.BalanceUpdateInterface; import com.herbron.moodl.DataManagers.BalanceManager; import com.herbron.moodl.DataManagers.CurrencyData.Currency; @@ -180,6 +181,7 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface, refreshLayout.setRefreshing(false); showErrorSnackbar(); + Log.d("moodl", "Error > Refresh out of time"); } if (loadingDialog.isShowing()) @@ -187,6 +189,7 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface, loadingDialog.dismiss(); showErrorSnackbar(); + Log.d("moodl", "Error > Refresh out of time"); } } }; @@ -242,7 +245,7 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface, addCurrencyButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Intent addIntent = new Intent(getActivity(), CurrencySelectionActivity.class); + Intent addIntent = new Intent(getActivity(), RecordTransactionActivity.class); startActivity(addIntent); } 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 a278e9d..b904cee 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionActivity.java @@ -4,6 +4,8 @@ import android.content.Intent; import android.os.Bundle; import android.support.design.widget.TextInputLayout; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.SearchView; +import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; @@ -47,6 +49,8 @@ public class RecordTransactionActivity extends AppCompatActivity { private Currency currency; private int transactionId; + private SearchView mainSearchView; + @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); @@ -54,7 +58,7 @@ public class RecordTransactionActivity extends AppCompatActivity { return true; } - @Override + /*@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_record: @@ -94,7 +98,7 @@ public class RecordTransactionActivity extends AppCompatActivity { break; } return true; - } + }*/ private boolean checkPriceText() { @@ -160,14 +164,18 @@ public class RecordTransactionActivity extends AppCompatActivity { databaseManager = new DatabaseManager(this); preferenceManager = new PreferencesManager(this); - initializeViewElements(); + //initializeViewElements(); coin = intent.getStringExtra("coin"); symbol = intent.getStringExtra("symbol"); transactionId = intent.getIntExtra("transactionId", -1); - if(transactionId != -1) + Toolbar toolbar = findViewById(R.id.searchCurrencyToolbar); + + setSupportActionBar(toolbar); + + /*if(transactionId != -1) { setTitle(PlaceholderManager.getEditTransactionString(coin, getBaseContext())); @@ -206,17 +214,17 @@ public class RecordTransactionActivity extends AppCompatActivity { } }); - initializeButtons(); + //initializeButtons(); currency.getTimestampPrice(this, preferenceManager.getDefaultCurrency(), new Currency.PriceCallBack() { @Override public void onSuccess(String price) { purchasedPriceEditText.setText(price); } - }, calendar.getTimeInMillis() / 1000); + }, calendar.getTimeInMillis() / 1000);*/ } - private void initializeButtons() + /*private void initializeButtons() { buyButton.setOnClickListener(new View.OnClickListener() { @Override @@ -262,7 +270,7 @@ public class RecordTransactionActivity extends AppCompatActivity { buyButton = findViewById(R.id.buyButton); sellButton = findViewById(R.id.sellButton); transferButton = findViewById(R.id.transfertButton); - } + }*/ private void createDatePicker() { diff --git a/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java b/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java index b920683..a08fd4f 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java @@ -288,57 +288,58 @@ public class SettingsActivity extends AppCompatPreferenceActivity { { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getContext()); FingerprintDialogFragment newFragment = FingerprintDialogFragment.newInstance(); + SwitchPreference touchdIdSwitch = (SwitchPreference) findPreference("enable_fingerprint"); + + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) + { + keyguardManager = (KeyguardManager) this.getActivity().getSystemService(KEYGUARD_SERVICE); + fingerprintManager = (FingerprintManager) this.getActivity().getSystemService(FINGERPRINT_SERVICE); + + try { + if(!fingerprintManager.isHardwareDetected()) + { + touchdIdSwitch.setEnabled(false); + } + + if(ActivityCompat.checkSelfPermission(this.getContext(), Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) + { + touchdIdSwitch.setEnabled(false); + } + + if(!fingerprintManager.hasEnrolledFingerprints()) + { + touchdIdSwitch.setEnabled(false); + } + + if(!keyguardManager.isKeyguardSecure()) + { + touchdIdSwitch.setEnabled(false); + } + else + { + try { + generateKey(); + } catch (FingerprintException e) { + e.printStackTrace(); + } + + if(initCipher()) + { + cryptoObject = new FingerprintManager.CryptoObject(cipher); + + FingerprintHandler helper = new FingerprintHandler(this.getContext(), newFragment); + helper.startAuth(fingerprintManager, cryptoObject); + } + } + } catch (NullPointerException e) { + e.printStackTrace(); + } + } if(preferences.getBoolean("enable_fingerprint", false)) { newFragment.setCancelable(false); newFragment.show(getFragmentManager(), "dialog"); - - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) - { - keyguardManager = (KeyguardManager) this.getActivity().getSystemService(KEYGUARD_SERVICE); - fingerprintManager = (FingerprintManager) this.getActivity().getSystemService(FINGERPRINT_SERVICE); - - try { - if(!fingerprintManager.isHardwareDetected()) - { - this.getActivity().findViewById(R.id.fingerprint_switch).setVisibility(View.GONE); - } - - if(ActivityCompat.checkSelfPermission(this.getContext(), Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) - { - this.getActivity().findViewById(R.id.fingerprint_switch).setVisibility(View.GONE); - } - - if(!fingerprintManager.hasEnrolledFingerprints()) - { - this.getActivity().findViewById(R.id.fingerprint_switch).setVisibility(View.GONE); - } - - if(!keyguardManager.isKeyguardSecure()) - { - this.getActivity().findViewById(R.id.fingerprint_switch).setVisibility(View.GONE); - } - else - { - try { - generateKey(); - } catch (FingerprintException e) { - e.printStackTrace(); - } - - if(initCipher()) - { - cryptoObject = new FingerprintManager.CryptoObject(cipher); - - FingerprintHandler helper = new FingerprintHandler(this.getContext(), newFragment); - helper.startAuth(fingerprintManager, cryptoObject); - } - } - } catch (NullPointerException e) { - e.printStackTrace(); - } - } } } @@ -720,9 +721,29 @@ public class SettingsActivity extends AppCompatPreferenceActivity { for(int i = 0; i < watchlistArray.length(); i++) { - JSONObject transactionObject = watchlistArray.getJSONObject(i); + JSONObject watchlistObject = watchlistArray.getJSONObject(i); - databaseManager.addRowWatchlist(transactionObject, getContext(), enterPasswordCheckbox.isChecked()); + databaseManager.addRowWatchlist(watchlistObject, getContext(), enterPasswordCheckbox.isChecked()); + } + } + } + + if(restoreApiKeysCheckbox.isChecked()) + { + if(wipeApiKeyxCheckbox.isChecked()) + { + databaseManager.wipeData(DatabaseManager.TABLE_EXCHANGE_KEYS); + } + + if(backupJson.has("apiKeys")) + { + JSONArray apiArray = backupJson.getJSONArray("apiKeys"); + + for(int i = 0; i < apiArray.length(); i++) + { + JSONObject apiKeysObject = apiArray.getJSONObject(i); + + databaseManager.addRowApiKeys(apiKeysObject, getContext(), enterPasswordCheckbox.isChecked()); } } } diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java b/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java index 398db93..2d5018d 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java @@ -96,25 +96,13 @@ public class BalanceManager { public void updateExchangeKeys() { - String publicKey = preferenceManager.getHitBTCPublicKey(); - String privateKey = preferenceManager.getHitBTCPrivateKey(); - hitBtcManagers.clear(); - if(preferenceManager.isHitBTCActivated() && publicKey != null && privateKey != null) - { - hitBtcManagers.add(new HitBtcManager(context, publicKey, privateKey)); - } - - publicKey = preferenceManager.getBinancePublicKey(); - privateKey = preferenceManager.getBinancePrivateKey(); + hitBtcManagers = databaseManager.getHitBtcAccounts(context); binanceManagers.clear(); - if(preferenceManager.isBinanceActivated() && publicKey != null && privateKey != null) - { - binanceManagers.add(new BinanceManager(publicKey, privateKey)); - } + binanceManagers = databaseManager.getBinanceAccounts(); } public List getTotalBalance() diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyDetailsList.java b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyDetailsList.java index 9d53637..c3d9aab 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyDetailsList.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyDetailsList.java @@ -71,6 +71,11 @@ public class CurrencyDetailsList { public boolean isUpToDate() { + if(coinInfosHashmap == null) + { + upToDate = false; + } + return upToDate; } diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyTickerList.java b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyTickerList.java index 4658027..8769dfd 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyTickerList.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyTickerList.java @@ -49,6 +49,11 @@ public class CurrencyTickerList { public boolean isUpToDate() { + if(currencyTickerList == null) + { + upToDate = false; + } + return upToDate; } 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 d33df71..a66fddc 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java @@ -9,13 +9,17 @@ import android.util.Log; import com.herbron.moodl.DataManagers.CurrencyData.Currency; import com.herbron.moodl.DataManagers.CurrencyData.Transaction; +import com.herbron.moodl.DataManagers.ExchangeManager.BinanceManager; +import com.herbron.moodl.DataManagers.ExchangeManager.HitBtcManager; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; +import java.util.Iterator; import java.util.List; /** @@ -24,7 +28,7 @@ import java.util.List; public class DatabaseManager extends SQLiteOpenHelper{ - private static final int DATABASE_VERSION = 7; + private static final int DATABASE_VERSION = 8; private static final String DATABASE_NAME = "Currencies.db"; @@ -43,6 +47,7 @@ public class DatabaseManager extends SQLiteOpenHelper{ private static final String KEY_EXCHANGE_ID = "idExchange"; private static final String KEY_EXCHANGE_NAME = "name"; + private static final String KEY_EXCHANGE_TYPE = "type"; private static final String KEY_EXCHANGE_DESCRIPTION = "description"; private static final String KEY_EXCHANGE_PUBLIC_KEY = "publicKey"; private static final String KEY_EXCHANGE_SECRET_KEY = "secretKey"; @@ -52,6 +57,9 @@ public class DatabaseManager extends SQLiteOpenHelper{ private static final String KEY_WATCHLIST_NAME = "name"; private static final String KEY_WATCHLIST_POSITION = "position"; + private static final int BINANCE_TYPE = 0; + private static final int HITBTC_TYPE = 1; + public DatabaseManager(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); @@ -73,6 +81,7 @@ public class DatabaseManager extends SQLiteOpenHelper{ db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_EXCHANGE_KEYS + "(" + KEY_EXCHANGE_ID + " INTEGER PRIMARY KEY," + + KEY_EXCHANGE_TYPE + " INTEGER," + KEY_EXCHANGE_NAME + " TEXT," + KEY_EXCHANGE_DESCRIPTION + " TEXT," + KEY_EXCHANGE_PUBLIC_KEY + " TEXT," @@ -96,7 +105,10 @@ public class DatabaseManager extends SQLiteOpenHelper{ { case 6: db.execSQL("ALTER TABLE " + TABLE_EXCHANGE_KEYS - + " ADD " + KEY_EXCHANGE_DESCRIPTION+ " VARCHAR"); + + " ADD " + KEY_EXCHANGE_DESCRIPTION + " TEXT"); + case 7: + db.execSQL("ALTER TABLE " + TABLE_EXCHANGE_KEYS + + " ADD " + KEY_EXCHANGE_TYPE + " INTEGER"); } } @@ -198,6 +210,9 @@ public class DatabaseManager extends SQLiteOpenHelper{ backupArray.put(backupObject); } + result.close(); + db.close(); + return backupArray; } @@ -207,6 +222,49 @@ public class DatabaseManager extends SQLiteOpenHelper{ db.execSQL("DELETE FROM "+ table); } + public void addRawData(Context context, JSONObject rawValues, String table, boolean decrypt) + { + SQLiteDatabase db = this.getWritableDatabase(); + ContentValues values = new ContentValues(); + + while(rawValues.keys().hasNext()) + { + String key = rawValues.keys().next(); + + try { + if(decrypt) + { + values.put(key, DataCrypter.decrypt(context, rawValues.getString(key))); + } + else + { + values.put(key, rawValues.getString(key)); + } + } catch (JSONException e) { + Log.d("moodl", "Error while inserting " + key + " " + e.getMessage()); + } + } + + db.insert(table, null, values); + db.close(); + } + + public void addRowApiKeys(JSONObject rawValues, Context context, boolean decrypt) + { + SQLiteDatabase db = this.getWritableDatabase(); + ContentValues values = new ContentValues(); + + try { + + if(decrypt) + { + values.put(KEY_EXCHANGE_NAME, DataCrypter.decrypt(context, rawValues.getString(KEY_WATCHLIST_SYMBOL))); + } + } catch (JSONException e) { + Log.d("moodl", "Error while inserting api key " + e.getMessage()); + } + } + public void addRowWatchlist(JSONObject rawValues, Context context, boolean decrypt) { SQLiteDatabase db = this.getWritableDatabase(); @@ -226,10 +284,10 @@ public class DatabaseManager extends SQLiteOpenHelper{ values.put(KEY_WATCHLIST_POSITION, rawValues.getString(KEY_WATCHLIST_POSITION)); } } catch (JSONException e) { - Log.d("moodl", "Error while inserting transaction"); + Log.d("moodl", "Error while inserting watchlist " + e.getMessage()); } - db.insert(TABLE_MANUAL_CURRENCIES, null, values); + db.insert(TABLE_WATCHLIST, null, values); db.close(); } @@ -260,7 +318,7 @@ public class DatabaseManager extends SQLiteOpenHelper{ values.put(KEY_CURRENCY_FEES, rawValues.getString(KEY_CURRENCY_FEES)); } } catch (JSONException e) { - Log.d("moodl", "Error while inserting transaction"); + Log.d("moodl", "Error while inserting transaction " + e.getMessage()); } db.insert(TABLE_MANUAL_CURRENCIES, null, values); @@ -280,22 +338,48 @@ public class DatabaseManager extends SQLiteOpenHelper{ currencyList.add(new Currency(resultList.getString(2), resultList.getString(1))); } + resultList.close(); + db.close(); + return currencyList; } - public void addCurrencyToManualCurrency(String symbol, double balance, Date date, double purchasedPrice, double fees) + public List getHitBtcAccounts(Context context) { + String searchQuerry = "SELECT * FROM " + TABLE_EXCHANGE_KEYS + " WHERE " + KEY_EXCHANGE_TYPE + "='" + HITBTC_TYPE + "'"; SQLiteDatabase db = this.getWritableDatabase(); - ContentValues values = new ContentValues(); + Cursor resultList = db.rawQuery(searchQuerry, null); - values.put(KEY_CURRENCY_SYMBOL, symbol); - values.put(KEY_CURRENCY_BALANCE, balance); - values.put(KEY_CURRENCY_DATE, date.getTime()); - values.put(KEY_CURRENCY_PURCHASED_PRICE, purchasedPrice); - values.put(KEY_CURRENCY_FEES, fees); + List accountList = new ArrayList<>(); - db.insert(TABLE_MANUAL_CURRENCIES, null, values); + while(resultList.moveToNext()) + { + accountList.add(new HitBtcManager(context, resultList.getString(4), resultList.getString(5))); + } + + resultList.close(); db.close(); + + return accountList; + } + + public List getBinanceAccounts() + { + String searchQuerry = "SELECT * FROM " + TABLE_EXCHANGE_KEYS + " WHERE " + KEY_EXCHANGE_TYPE + "='" + BINANCE_TYPE + "'"; + SQLiteDatabase db = this.getWritableDatabase(); + Cursor resultList = db.rawQuery(searchQuerry, null); + + List accountList = new ArrayList<>(); + + while(resultList.moveToNext()) + { + accountList.add(new BinanceManager(resultList.getString(4), resultList.getString(5))); + } + + resultList.close(); + db.close(); + + return accountList; } public List getAllCurrenciesFromManualCurrency() 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 0a6d95d..4110957 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/PreferencesManager.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/PreferencesManager.java @@ -48,6 +48,16 @@ public class PreferencesManager { 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); @@ -74,16 +84,6 @@ public class PreferencesManager { editor.apply(); } - public String getBinancePublicKey() - { - return settingPreferences.getString("binance_publickey", null); - } - - public String getBinancePrivateKey() - { - return settingPreferences.getString("binance_privatekey", null); - } - public boolean isBinanceActivated() { return settingPreferences.getBoolean("enable_binance", false); diff --git a/app/src/main/res/layout/activity_record_transaction.xml b/app/src/main/res/layout/activity_record_transaction.xml index 28fc376..998c41a 100644 --- a/app/src/main/res/layout/activity_record_transaction.xml +++ b/app/src/main/res/layout/activity_record_transaction.xml @@ -3,15 +3,24 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + xmlns:app="http://schemas.android.com/apk/res-auto" tools:context="com.herbron.moodl.Activities.RecordTransactionActivity"> - + android:layout_height="wrap_content" + android:background="@color/colorPrimary" + android:minHeight="?attr/actionBarSize" + app:theme="@style/ThemeOverlay.AppCompat.Dark" /> - + - - + --> diff --git a/app/src/main/res/menu/menu_record_action.xml b/app/src/main/res/menu/menu_record_action.xml index 59275d4..ba39a95 100644 --- a/app/src/main/res/menu/menu_record_action.xml +++ b/app/src/main/res/menu/menu_record_action.xml @@ -2,9 +2,11 @@ - + \ No newline at end of file From a64aed47292f0cb4b15216ce0722bbb3b96f46d9 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Tue, 31 Jul 2018 13:16:42 +0200 Subject: [PATCH 02/41] Update exchange activity --- .idea/caches/build_file_checksums.ser | Bin 540 -> 545 bytes .../Activities/ExchangeListActivity.java | 70 ++++++++++++++++++ .../moodl/Activities/SettingsActivity.java | 17 ++++- .../ExchangeManager/Exchange.java | 31 ++++++++ .../LayoutManagers/ExchangeListAdapter.java | 53 +++++++++++++ .../res/layout/activity_exchange_list.xml | 33 +++++++++ .../main/res/layout/content_exchange_list.xml | 16 ++++ app/src/main/res/layout/exchange_cell.xml | 41 ++++++++++ app/src/main/res/xml/pref_main.xml | 1 - 9 files changed, 260 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/herbron/moodl/Activities/ExchangeListActivity.java create mode 100644 app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/Exchange.java create mode 100644 app/src/main/java/com/herbron/moodl/LayoutManagers/ExchangeListAdapter.java create mode 100644 app/src/main/res/layout/activity_exchange_list.xml create mode 100644 app/src/main/res/layout/content_exchange_list.xml create mode 100644 app/src/main/res/layout/exchange_cell.xml diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 9b9448ccb03674b8e21339225f424dd4004f500e..b761e370049dffc332bab16b6be4318abdfc2347 100644 GIT binary patch delta 81 zcmV-X0IvU>1fc|wm;~*^Pfn4XwUe0vL^7xp5}ld>Xcf?C5YOMJAn0@eFhe?ARdZ!> nb6i1WZE0?4b98cHbZ>H8E@yIKWNc+zlkfo>lZOEklkWj7TudN} delta 75 zcmV-R0JQ(11e^qrm;}5RawU exchangeList = new ArrayList<>(); + exchangeList.add(new Exchange(0, "Main account", BINANCE_TYPE, "Account with main balance & trading bot", "0000", "0000")); + exchangeList.add(new Exchange(1, "Hit account", HITBTC_TYPE, "BCN account and HIT", "0001", "0001")); + + ExchangeListAdapter exchangeListAdapter = new ExchangeListAdapter(getApplicationContext(), exchangeList); + + exchangeListView = findViewById(R.id.exchange_listView); + exchangeListView.setAdapter(exchangeListAdapter); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if (id == android.R.id.home) { + finish(); + return true; + } + + return super.onOptionsItemSelected(item); + } + +} diff --git a/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java b/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java index a08fd4f..ec09c8b 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java @@ -6,6 +6,7 @@ import android.app.AlertDialog; import android.app.KeyguardManager; import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Configuration; @@ -234,7 +235,9 @@ public class SettingsActivity extends AppCompatPreferenceActivity { @Override public boolean onPreferenceChange(Preference preference, Object o) { - return false; + Log.d("moodl", "> " + o + " " + preference); + + return (boolean) o; } }); @@ -777,6 +780,17 @@ public class SettingsActivity extends AppCompatPreferenceActivity { } }); + findPreference("exchange").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + + Intent exchangeListIntent = new Intent(getContext(), ExchangeListActivity.class); + startActivity(exchangeListIntent); + + return false; + } + }); + EditTextPreference editTextPreference = (EditTextPreference) findPreference("minimum_value_displayed"); editTextPreference.setPositiveButtonText(getString(R.string.save)); editTextPreference.setNegativeButtonText(getString(R.string.cancel)); @@ -832,6 +846,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity { //startActivity(new Intent(getActivity(), SettingsActivity.class)); return true; } + return super.onOptionsItemSelected(item); } } diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/Exchange.java b/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/Exchange.java new file mode 100644 index 0000000..173a316 --- /dev/null +++ b/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/Exchange.java @@ -0,0 +1,31 @@ +package com.herbron.moodl.DataManagers.ExchangeManager; + +public class Exchange { + + protected int id; + protected String name; + protected int type; + protected String description; + protected String publicKey; + protected String privateKey; + + public Exchange(int id, String name, int type, String description, String publicKey, String privateKey) + { + this.id = id; + this.name = name; + this.type = type; + this.description = description; + this.publicKey = publicKey; + this.privateKey = privateKey; + } + + public String getName() + { + return name; + } + + public String getDescription() + { + return description; + } +} diff --git a/app/src/main/java/com/herbron/moodl/LayoutManagers/ExchangeListAdapter.java b/app/src/main/java/com/herbron/moodl/LayoutManagers/ExchangeListAdapter.java new file mode 100644 index 0000000..5c7bfe3 --- /dev/null +++ b/app/src/main/java/com/herbron/moodl/LayoutManagers/ExchangeListAdapter.java @@ -0,0 +1,53 @@ +package com.herbron.moodl.LayoutManagers; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.BaseAdapter; +import android.widget.Filter; +import android.widget.Filterable; +import android.widget.TextView; + +import com.herbron.moodl.DataManagers.CurrencyData.Currency; +import com.herbron.moodl.DataManagers.CurrencyData.Trade; +import com.herbron.moodl.DataManagers.ExchangeManager.Exchange; +import com.herbron.moodl.R; + +import java.util.ArrayList; + +import static com.herbron.moodl.MoodlBox.getDateFromTimestamp; + +public class ExchangeListAdapter extends ArrayAdapter { + + private Context context; + + public ExchangeListAdapter(Context context, ArrayList exchanges) + { + super(context, android.R.layout.simple_list_item_1, exchanges); + this.context = context; + } + + @NonNull + @Override + public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + Exchange exchange = getItem(position); + + if(convertView == null) + { + convertView = LayoutInflater.from(getContext()).inflate(R.layout.exchange_cell, parent, false); + } + + TextView exchangeNameTextView = convertView.findViewById(R.id.exchange_name); + TextView exchangeDescriptionTextView = convertView.findViewById(R.id.exchange_description); + + exchangeNameTextView.setText(exchange.getName()); + exchangeDescriptionTextView.setText(exchange.getDescription()); + + return convertView; + } + +} diff --git a/app/src/main/res/layout/activity_exchange_list.xml b/app/src/main/res/layout/activity_exchange_list.xml new file mode 100644 index 0000000..191ec64 --- /dev/null +++ b/app/src/main/res/layout/activity_exchange_list.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/content_exchange_list.xml b/app/src/main/res/layout/content_exchange_list.xml new file mode 100644 index 0000000..be2d1e7 --- /dev/null +++ b/app/src/main/res/layout/content_exchange_list.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/exchange_cell.xml b/app/src/main/res/layout/exchange_cell.xml new file mode 100644 index 0000000..e7ffe0e --- /dev/null +++ b/app/src/main/res/layout/exchange_cell.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index bd9495e..7772bd9 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -39,7 +39,6 @@ android:title="@string/pref_title_category_synchronization"> From 380716f7ead9190088ef38073476b146d97ab693 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Wed, 1 Aug 2018 01:02:41 +0200 Subject: [PATCH 03/41] Exchange config rework - Fix crash when binance sync error - New exchange list UI - New exchange configuration UI - Fix gradient background for Settings activity The new exchange configuration interface allows you to add (it should work) multiple accounts for each exchange If an account's keys are incorrect, the account and disabled and it's notified in the exchange list You can edit the exchange account later from the exchange list activity --- .idea/assetWizardSettings.xml | 10 +- .idea/caches/build_file_checksums.ser | Bin 545 -> 545 bytes app/build.gradle | 8 +- app/src/main/AndroidManifest.xml | 8 +- .../moodl/Activities/AddExchangeActivity.java | 173 ++++++++++++++++++ .../Transactions.java | 6 +- .../Activities/ExchangeListActivity.java | 21 ++- .../HomeActivityFragments/Summary.java | 7 +- .../moodl/Activities/SettingsActivity.java | 6 + .../moodl/DataManagers/BalanceManager.java | 18 +- .../moodl/DataManagers/DatabaseManager.java | 108 ++++++++++- .../ExchangeManager/BinanceManager.java | 12 +- .../ExchangeManager/Exchange.java | 29 ++- .../ExchangeManager/HitBtcManager.java | 11 +- .../LayoutManagers/CurrencyListAdapter.java | 2 +- .../LayoutManagers/ExchangeListAdapter.java | 32 ++++ .../main/res/drawable/ic_add_white_24dp.xml | 5 + .../ic_arrow_drop_down_white_24dp.xml | 5 + .../main/res/drawable/ic_money_off_24dp.xml | 5 + .../main/res/drawable/spinner_background.xml | 21 +++ .../main/res/layout/activity_add_exchange.xml | 74 ++++++++ .../layout/binance_exchange_setup_layout.xml | 93 ++++++++++ app/src/main/res/layout/cardview_currency.xml | 18 +- .../main/res/layout/cardview_watchlist.xml | 12 +- app/src/main/res/layout/exchange_cell.xml | 119 +++++++++--- .../main/res/layout/exchange_spinner_item.xml | 9 + .../layout/hitbtc_exchange_setup_layout.xml | 93 ++++++++++ app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values/arrays.xml | 7 + app/src/main/res/values/colors.xml | 5 +- app/src/main/res/values/dimens.xml | 5 +- app/src/main/res/values/strings.xml | 7 + app/src/main/res/values/styles.xml | 2 +- 33 files changed, 834 insertions(+), 98 deletions(-) create mode 100644 app/src/main/java/com/herbron/moodl/Activities/AddExchangeActivity.java create mode 100644 app/src/main/res/drawable/ic_add_white_24dp.xml create mode 100644 app/src/main/res/drawable/ic_arrow_drop_down_white_24dp.xml create mode 100644 app/src/main/res/drawable/ic_money_off_24dp.xml create mode 100644 app/src/main/res/drawable/spinner_background.xml create mode 100644 app/src/main/res/layout/activity_add_exchange.xml create mode 100644 app/src/main/res/layout/binance_exchange_setup_layout.xml create mode 100644 app/src/main/res/layout/exchange_spinner_item.xml create mode 100644 app/src/main/res/layout/hitbtc_exchange_setup_layout.xml create mode 100644 app/src/main/res/values/arrays.xml diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml index ae12ad6..0e83d31 100644 --- a/.idea/assetWizardSettings.xml +++ b/.idea/assetWizardSettings.xml @@ -3,6 +3,11 @@ diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index b761e370049dffc332bab16b6be4318abdfc2347..9c090e5037b5e0263a349d1ec3d92be60f542163 100644 GIT binary patch delta 35 tcmV+;0Nnqf1fc|wm;~`0sPK`TcM!o;C*mGwBOQ>fj$iFGach$!0sa?U503x< delta 35 tcmV+;0Nnqf1fc|wm;~*^Pfn4XcMyGc@sJezHAkSxB5o2WWu}uO0sa`e4`~1Z diff --git a/app/build.gradle b/app/build.gradle index 4c54bf0..f848c74 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,6 +12,10 @@ android { vectorDrawables.useSupportLibrary = true } + aaptOptions { + additionalParameters "--no-version-vectors" + } + dataBinding { enabled = true } @@ -34,12 +38,12 @@ android { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support:support-v4:27.1.1' implementation 'com.android.support:design:27.1.1' implementation 'com.android.support:cardview-v7:27.1.1' implementation 'com.mcxiaoke.volley:library:1.0.19' implementation 'com.diogobernardino:williamchart:2.5.0' implementation 'com.android.support.constraint:constraint-layout:1.1.2' - implementation 'com.android.support:support-v4:27.1.1' implementation 'com.android.support:palette-v7:27.1.1' implementation 'com.daimajia.swipelayout:library:1.2.0@aar' implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.5' @@ -61,5 +65,5 @@ dependencies { androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation files('../libs/binance-api.jar') - implementation files('../libs/commons-codec-1.11.jar'); + implementation files('../libs/commons-codec-1.11.jar') } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1b4bdb1..4620055 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -43,7 +43,7 @@ + android:theme="@style/InputActivityTheme"> @@ -56,6 +56,12 @@ android:name="android.support.PARENT_ACTIVITY" android:value="com.herbron.moodl.Activities.HomeActivity" /> + + \ No newline at end of file diff --git a/app/src/main/java/com/herbron/moodl/Activities/AddExchangeActivity.java b/app/src/main/java/com/herbron/moodl/Activities/AddExchangeActivity.java new file mode 100644 index 0000000..5dca0ed --- /dev/null +++ b/app/src/main/java/com/herbron/moodl/Activities/AddExchangeActivity.java @@ -0,0 +1,173 @@ +package com.herbron.moodl.Activities; + +import android.content.Intent; +import android.support.design.widget.TextInputEditText; +import android.support.design.widget.TextInputLayout; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.support.v7.widget.AppCompatButton; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.ImageButton; +import android.widget.LinearLayout; +import android.widget.Spinner; + +import com.herbron.moodl.DataManagers.DatabaseManager; +import com.herbron.moodl.DataManagers.ExchangeManager.Exchange; +import com.herbron.moodl.R; + +public class AddExchangeActivity extends AppCompatActivity { + + private LinearLayout setupExchangeLayout; + private Spinner exchangeSpinner; + private DatabaseManager databaseManager; + + private TextInputEditText accountLabelEditText; + private TextInputEditText accountDescriptionEditText; + private TextInputEditText publicKeyEditText; + private TextInputEditText secretKeyEditText; + private AppCompatButton saveExchangeButton; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_add_exchange); + getApplicationContext().setTheme(R.style.InputActivityTheme); + + Toolbar toolbar = findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + databaseManager = new DatabaseManager(getBaseContext()); + + exchangeSpinner = findViewById(R.id.exchange_spinner); + + ArrayAdapter adapter = ArrayAdapter.createFromResource(this, + R.array.supported_exchanges, R.layout.exchange_spinner_item); + + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + + setupExchangeLayout = findViewById(R.id.exchange_setup_layout); + + exchangeSpinner.setAdapter(adapter); + + Intent callingIntent = getIntent(); + + if(callingIntent.getBooleanExtra("isEdit", false)) + { + startExchangeEditionForId(callingIntent.getIntExtra("exchangeId", -1)); + } + else + { + exchangeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + loadLayoutFor(position); + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + } + + setupBackButton(); + } + + private void loadLayoutFor(int exchangeType) + { + setupExchangeLayout.removeAllViews(); + + switch (exchangeType) + { + case DatabaseManager.BINANCE_TYPE: + setupExchangeLayout = (LinearLayout) LayoutInflater.from(getApplicationContext()).inflate(R.layout.binance_exchange_setup_layout, setupExchangeLayout, true); + + bindSetupViews(); + break; + case DatabaseManager.HITBTC_TYPE: + setupExchangeLayout = (LinearLayout) LayoutInflater.from(getApplicationContext()).inflate(R.layout.hitbtc_exchange_setup_layout, setupExchangeLayout, true); + + bindSetupViews(); + break; + } + } + + private void startExchangeEditionForId(int exchangeId) + { + Exchange exchangeInfos = databaseManager.getExchangeFromId(exchangeId); + + loadLayoutFor(exchangeInfos.getType()); + + exchangeSpinner.setEnabled(false); + + accountLabelEditText.setText(exchangeInfos.getName()); + accountDescriptionEditText.setText(exchangeInfos.getDescription()); + publicKeyEditText.setText(exchangeInfos.getPublicKey()); + secretKeyEditText.setText(exchangeInfos.getPrivateKey()); + + saveExchangeButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(isEditTextFilled(accountLabelEditText) && isEditTextFilled(publicKeyEditText) && isEditTextFilled(secretKeyEditText)) + { + databaseManager.deleteExchangeAccountFromId(exchangeInfos.getId()); + databaseManager.addExchange(accountLabelEditText.getText().toString(), exchangeSpinner.getSelectedItemPosition() + , accountDescriptionEditText.getText().toString(), publicKeyEditText.getText().toString() + , secretKeyEditText.getText().toString()); + finish(); + } + } + }); + } + + private void bindSetupViews() + { + accountLabelEditText = findViewById(R.id.account_label_editText); + accountDescriptionEditText = findViewById(R.id.account_description_editText); + publicKeyEditText = findViewById(R.id.publicKey_editText); + secretKeyEditText = findViewById(R.id.secretKey_editText); + + saveExchangeButton = findViewById(R.id.saveExchangeButton); + + saveExchangeButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if(isEditTextFilled(accountLabelEditText) && isEditTextFilled(publicKeyEditText) && isEditTextFilled(secretKeyEditText)) + { + databaseManager.addExchange(accountLabelEditText.getText().toString(), exchangeSpinner.getSelectedItemPosition() + , accountDescriptionEditText.getText().toString(), publicKeyEditText.getText().toString() + , secretKeyEditText.getText().toString()); + + finish(); + } + } + }); + } + + private boolean isEditTextFilled(TextInputEditText editText) + { + if(editText.getText().toString().equals("") || editText.getText().toString().equals(" ")) + { + editText.setError(getResources().getString(R.string.must_be_filled)); + + return false; + } + + return true; + } + + private void setupBackButton() + { + ImageButton backButton = findViewById(R.id.back_button); + backButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + } +} diff --git a/app/src/main/java/com/herbron/moodl/Activities/DetailsActivityFragments/Transactions.java b/app/src/main/java/com/herbron/moodl/Activities/DetailsActivityFragments/Transactions.java index 4ab12ad..7798cf2 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/DetailsActivityFragments/Transactions.java +++ b/app/src/main/java/com/herbron/moodl/Activities/DetailsActivityFragments/Transactions.java @@ -54,7 +54,7 @@ public class Transactions extends Fragment { currency = getActivity().getIntent().getParcelableExtra("currency"); databaseManager = new DatabaseManager(getContext()); - binanceManager = new BinanceManager(preferencesManager.getBinancePublicKey(), preferencesManager.getBinancePrivateKey()); + //binanceManager = new BinanceManager(preferencesManager.getBinancePublicKey(), preferencesManager.getBinancePrivateKey()); tradeLayout = view.findViewById(R.id.listTrades); transactionLayout = view.findViewById(R.id.listTransactions); @@ -63,8 +63,8 @@ public class Transactions extends Fragment { TransactionUpdater transactionUpdater = new TransactionUpdater(); transactionUpdater.execute(); - TradeUpdater updater = new TradeUpdater(); - updater.execute(); + /*TradeUpdater updater = new TradeUpdater(); + updater.execute();*/ return view; } diff --git a/app/src/main/java/com/herbron/moodl/Activities/ExchangeListActivity.java b/app/src/main/java/com/herbron/moodl/Activities/ExchangeListActivity.java index 053a6f6..df06da0 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/ExchangeListActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/ExchangeListActivity.java @@ -1,5 +1,6 @@ package com.herbron.moodl.Activities; +import android.content.Intent; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; @@ -24,6 +25,7 @@ public class ExchangeListActivity extends AppCompatActivity { private DatabaseManager databaseManager; private ListView exchangeListView; + private ExchangeListAdapter exchangeListAdapter; @Override protected void onCreate(Bundle savedInstanceState) { @@ -37,11 +39,7 @@ public class ExchangeListActivity extends AppCompatActivity { databaseManager = new DatabaseManager(this); - ArrayList exchangeList = new ArrayList<>(); - exchangeList.add(new Exchange(0, "Main account", BINANCE_TYPE, "Account with main balance & trading bot", "0000", "0000")); - exchangeList.add(new Exchange(1, "Hit account", HITBTC_TYPE, "BCN account and HIT", "0001", "0001")); - - ExchangeListAdapter exchangeListAdapter = new ExchangeListAdapter(getApplicationContext(), exchangeList); + exchangeListAdapter = new ExchangeListAdapter(getApplicationContext(), databaseManager.getExchanges()); exchangeListView = findViewById(R.id.exchange_listView); exchangeListView.setAdapter(exchangeListAdapter); @@ -50,12 +48,21 @@ public class ExchangeListActivity extends AppCompatActivity { fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) - .setAction("Action", null).show(); + Intent intent = new Intent(ExchangeListActivity.this, AddExchangeActivity.class); + startActivity(intent); } }); } + @Override + protected void onResume() { + super.onResume(); + + exchangeListAdapter.clear(); + exchangeListAdapter.addAll(databaseManager.getExchanges()); + exchangeListAdapter.notifyDataSetChanged(); + } + @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); 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 29ec6be..98b08f9 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 @@ -585,7 +585,12 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface, @Override public void onBalanceError(String error) { - generateSnackBarError(error); + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + generateSnackBarError(error); + } + }); } private void generateSnackBarError(String error) diff --git a/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java b/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java index da88323..84c2a64 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java +++ b/app/src/main/java/com/herbron/moodl/Activities/SettingsActivity.java @@ -10,6 +10,8 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Configuration; +import android.content.res.Resources; +import android.graphics.drawable.Drawable; import android.hardware.fingerprint.FingerprintManager; import android.os.Build; import android.os.Bundle; @@ -179,6 +181,10 @@ public class SettingsActivity extends AppCompatPreferenceActivity { // Show the Up button in the action bar. actionBar.setDisplayHomeAsUpEnabled(true); } + + Drawable gradientDrawable = getResources().getDrawable(R.drawable.gradient_background); + + actionBar.setBackgroundDrawable(gradientDrawable); } /** diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java b/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java index 2d5018d..7e1cf05 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java @@ -26,14 +26,6 @@ import java.util.List; public class BalanceManager { - private String publicHitKey; - private String publicBinanceKey; - private String publicPoloniex; - private String privateHitKey; - private String privateBinanceKey; - private String privatePoloniex; - final private String hitBalanceUrl = "https://api.hitbtc.com/api/2/trading/balance"; - final private String detailUrl = "https://www.cryptocompare.com/api/data/coinlist/"; private RequestQueue requestQueue; private List binanceBalance; private List hitBalance; @@ -103,6 +95,8 @@ public class BalanceManager { binanceManagers.clear(); binanceManagers = databaseManager.getBinanceAccounts(); + + Log.d("moodl", "Number of binance accounts " + binanceManagers.size()); } public List getTotalBalance() @@ -113,6 +107,8 @@ public class BalanceManager { public void updateTotalBalance() { boolean isUpdated = false; + + updateExchangeKeys(); balanceCounter = 0; @@ -124,6 +120,7 @@ public class BalanceManager { for(int i = 0; i < binanceManagers.size(); i++) { + final int index = i; binanceManagers.get(i).updateBalance(new BinanceManager.BinanceCallBack() { @Override public void onSuccess() { @@ -132,6 +129,7 @@ public class BalanceManager { @Override public void onError(String error) { + databaseManager.disableExchangeAccount(binanceManagers.get(index).getId()); dataNotifierInterface.onBalanceError(error); } }); @@ -298,6 +296,8 @@ public class BalanceManager { currencyName = jsonObject.getString("CoinName"); } catch (JSONException e) { e.printStackTrace(); + } catch (NullPointerException e) { + currencyName = symbol; } return currencyName; @@ -312,6 +312,8 @@ public class BalanceManager { id = jsonObject.getInt("Id"); } catch (JSONException e) { e.printStackTrace(); + } catch (NullPointerException e) { + id = -1; } return id; 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 a66fddc..5fbbf2a 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java @@ -10,6 +10,7 @@ import android.util.Log; import com.herbron.moodl.DataManagers.CurrencyData.Currency; import com.herbron.moodl.DataManagers.CurrencyData.Transaction; import com.herbron.moodl.DataManagers.ExchangeManager.BinanceManager; +import com.herbron.moodl.DataManagers.ExchangeManager.Exchange; import com.herbron.moodl.DataManagers.ExchangeManager.HitBtcManager; import org.json.JSONArray; @@ -28,7 +29,7 @@ import java.util.List; public class DatabaseManager extends SQLiteOpenHelper{ - private static final int DATABASE_VERSION = 8; + private static final int DATABASE_VERSION = 10; private static final String DATABASE_NAME = "Currencies.db"; @@ -51,14 +52,15 @@ public class DatabaseManager extends SQLiteOpenHelper{ private static final String KEY_EXCHANGE_DESCRIPTION = "description"; private static final String KEY_EXCHANGE_PUBLIC_KEY = "publicKey"; private static final String KEY_EXCHANGE_SECRET_KEY = "secretKey"; + private static final String KEY_EXCHANGE_IS_ENABLED = "enabled"; private static final String KEY_WATCHLIST_ID = "idWatchlist"; private static final String KEY_WATCHLIST_SYMBOL = "symbol"; private static final String KEY_WATCHLIST_NAME = "name"; private static final String KEY_WATCHLIST_POSITION = "position"; - private static final int BINANCE_TYPE = 0; - private static final int HITBTC_TYPE = 1; + public static final int BINANCE_TYPE = 0; + public static final int HITBTC_TYPE = 1; public DatabaseManager(Context context) { @@ -81,11 +83,12 @@ public class DatabaseManager extends SQLiteOpenHelper{ db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_EXCHANGE_KEYS + "(" + KEY_EXCHANGE_ID + " INTEGER PRIMARY KEY," - + KEY_EXCHANGE_TYPE + " INTEGER," + KEY_EXCHANGE_NAME + " TEXT," + + KEY_EXCHANGE_TYPE + " INTEGER," + KEY_EXCHANGE_DESCRIPTION + " TEXT," + KEY_EXCHANGE_PUBLIC_KEY + " TEXT," - + KEY_EXCHANGE_SECRET_KEY + " TEXT" + + KEY_EXCHANGE_SECRET_KEY + " TEXT," + + KEY_EXCHANGE_IS_ENABLED + " INTEGER" + ");"); db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_WATCHLIST + "(" @@ -109,6 +112,12 @@ public class DatabaseManager extends SQLiteOpenHelper{ case 7: db.execSQL("ALTER TABLE " + TABLE_EXCHANGE_KEYS + " ADD " + KEY_EXCHANGE_TYPE + " INTEGER"); + case 8: + db.execSQL("DROP TABLE " + TABLE_EXCHANGE_KEYS); + onCreate(db); + case 9: + db.execSQL("ALTER TABLE " + TABLE_EXCHANGE_KEYS + + " ADD " + KEY_EXCHANGE_IS_ENABLED + " INTEGER"); } } @@ -151,7 +160,6 @@ public class DatabaseManager extends SQLiteOpenHelper{ cv.put(KEY_WATCHLIST_POSITION, position); db.update(TABLE_WATCHLIST, cv, KEY_WATCHLIST_SYMBOL + "='" + symbol + "'", null); - } private int getWatchlistRowCount(SQLiteDatabase db) @@ -164,6 +172,14 @@ public class DatabaseManager extends SQLiteOpenHelper{ return result.getInt(0); } + public void deleteExchangeAccountFromId(int id) + { + SQLiteDatabase db = this.getWritableDatabase(); + + db.delete(TABLE_EXCHANGE_KEYS, KEY_EXCHANGE_ID + " = " + id, null); + db.close(); + } + public void deleteCurrencyFromWatchlist(String symbol) { SQLiteDatabase db = this.getWritableDatabase(); @@ -172,6 +188,70 @@ public class DatabaseManager extends SQLiteOpenHelper{ db.close(); } + public void disableExchangeAccount(int id) + { + SQLiteDatabase db = this.getWritableDatabase(); + ContentValues cv = new ContentValues(); + + cv.put(KEY_EXCHANGE_IS_ENABLED, 0); + + db.update(TABLE_EXCHANGE_KEYS, cv, KEY_EXCHANGE_ID + "='" + id + "'", null); + } + + public Exchange getExchangeFromId(int exchangeId) + { + String selectQuerry = "SELECT * FROM " + TABLE_EXCHANGE_KEYS + " WHERE " + KEY_EXCHANGE_ID + " = " + exchangeId; + SQLiteDatabase db = this.getWritableDatabase(); + Cursor result = db.rawQuery(selectQuerry, null); + + Exchange selectedExchange = null; + + if(result.moveToFirst()) + { + selectedExchange = new Exchange(result.getInt(0), result.getString(1) + , result.getInt(2), result.getString(3) + , result.getString(4), result.getString(5) + , (result.getInt(6) == 1)); + } + + return selectedExchange; + } + + public ArrayList getExchanges() + { + String selectQuerry = "SELECT * FROM " + TABLE_EXCHANGE_KEYS; + SQLiteDatabase db = this.getWritableDatabase(); + Cursor result = db.rawQuery(selectQuerry, null); + + ArrayList exchanges = new ArrayList<>(); + + while(result.moveToNext()) + { + exchanges.add(new Exchange(result.getInt(0), result.getString(1) + , result.getInt(2), result.getString(3) + , result.getString(4), result.getString(5) + , (result.getInt(6) == 1))); + } + + return exchanges; + } + + public void addExchange(String name, int type, String description, String publicKey, String privateKey) + { + SQLiteDatabase db = this.getWritableDatabase(); + ContentValues values = new ContentValues(); + + values.put(KEY_EXCHANGE_NAME, name); + values.put(KEY_EXCHANGE_TYPE, type); + values.put(KEY_EXCHANGE_DESCRIPTION, description); + values.put(KEY_EXCHANGE_PUBLIC_KEY, publicKey); + values.put(KEY_EXCHANGE_SECRET_KEY, privateKey); + values.put(KEY_EXCHANGE_IS_ENABLED, 1); + + db.insert(TABLE_EXCHANGE_KEYS, null, values); + db.close(); + } + public JSONArray getDatabaseBackup(Context context, String table, boolean encryptData) { String selectQuerry = "SELECT * FROM " + table; @@ -346,7 +426,7 @@ public class DatabaseManager extends SQLiteOpenHelper{ public List getHitBtcAccounts(Context context) { - String searchQuerry = "SELECT * FROM " + TABLE_EXCHANGE_KEYS + " WHERE " + KEY_EXCHANGE_TYPE + "='" + HITBTC_TYPE + "'"; + String searchQuerry = "SELECT * FROM " + TABLE_EXCHANGE_KEYS + " WHERE " + KEY_EXCHANGE_TYPE + "='" + HITBTC_TYPE + "' AND " + KEY_EXCHANGE_IS_ENABLED + " = '1'"; SQLiteDatabase db = this.getWritableDatabase(); Cursor resultList = db.rawQuery(searchQuerry, null); @@ -354,7 +434,11 @@ public class DatabaseManager extends SQLiteOpenHelper{ while(resultList.moveToNext()) { - accountList.add(new HitBtcManager(context, resultList.getString(4), resultList.getString(5))); + Exchange exchange = new Exchange(resultList.getInt(0), resultList.getString(1) + , resultList.getInt(2), resultList.getString(3) + , resultList.getString(4), resultList.getString(5) + , (resultList.getInt(6) == 1)); + accountList.add(new HitBtcManager(context, exchange)); } resultList.close(); @@ -365,7 +449,7 @@ public class DatabaseManager extends SQLiteOpenHelper{ public List getBinanceAccounts() { - String searchQuerry = "SELECT * FROM " + TABLE_EXCHANGE_KEYS + " WHERE " + KEY_EXCHANGE_TYPE + "='" + BINANCE_TYPE + "'"; + String searchQuerry = "SELECT * FROM " + TABLE_EXCHANGE_KEYS + " WHERE " + KEY_EXCHANGE_TYPE + "='" + BINANCE_TYPE + "' AND " + KEY_EXCHANGE_IS_ENABLED + " = '1'"; SQLiteDatabase db = this.getWritableDatabase(); Cursor resultList = db.rawQuery(searchQuerry, null); @@ -373,7 +457,11 @@ public class DatabaseManager extends SQLiteOpenHelper{ while(resultList.moveToNext()) { - accountList.add(new BinanceManager(resultList.getString(4), resultList.getString(5))); + Exchange exchange = new Exchange(resultList.getInt(0), resultList.getString(1) + , resultList.getInt(2), resultList.getString(3) + , resultList.getString(4), resultList.getString(5) + , (resultList.getInt(6) == 1)); + accountList.add(new BinanceManager(exchange)); } resultList.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 3007b2d..3b9a747 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 @@ -17,19 +17,15 @@ import java.util.List; * Created by Guitoune on 26/02/2018. */ -public class BinanceManager { - - private String publicKey; - private String privateKey; +public class BinanceManager extends Exchange { private List balance; private ArrayList trades; - private List pairSymbolList; + private static List pairSymbolList; - public BinanceManager(String publicKey, String privateKey) + public BinanceManager(Exchange exchange) { - this.publicKey = publicKey; - this.privateKey = privateKey; + super(exchange.id, exchange.name, exchange.type, exchange.description, exchange.publicKey, exchange.privateKey, exchange.isEnabled); createPairSymbolList(); } diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/Exchange.java b/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/Exchange.java index 173a316..338c244 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/Exchange.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/Exchange.java @@ -8,8 +8,9 @@ public class Exchange { protected String description; protected String publicKey; protected String privateKey; + protected boolean isEnabled; - public Exchange(int id, String name, int type, String description, String publicKey, String privateKey) + public Exchange(int id, String name, int type, String description, String publicKey, String privateKey, boolean isEnabled) { this.id = id; this.name = name; @@ -17,6 +18,27 @@ public class Exchange { this.description = description; this.publicKey = publicKey; this.privateKey = privateKey; + this.isEnabled = isEnabled; + } + + public boolean isEnabled() + { + return isEnabled; + } + + public String getPublicKey() + { + return publicKey; + } + + public String getPrivateKey() + { + return privateKey; + } + + public int getType() + { + return type; } public String getName() @@ -28,4 +50,9 @@ public class Exchange { { return description; } + + public int getId() + { + return id; + } } diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/HitBtcManager.java b/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/HitBtcManager.java index b096c7e..9f89cd1 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/HitBtcManager.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/ExchangeManager/HitBtcManager.java @@ -26,10 +26,8 @@ import java.util.Map; * Created by Guitoune on 26/02/2018. */ -public class HitBtcManager { +public class HitBtcManager extends Exchange { - private String publicKey; - private String privateKey; final private String hitBalanceUrl = "https://api.hitbtc.com/api/2/account/balance"; final private String hitTradingBalanceUrl = "https://api.hitbtc.com/api/2/trading/balance"; final private String tradeHistoryUrl = "https://api.hitbtc.com/api/2/history/trades?"; @@ -41,13 +39,12 @@ public class HitBtcManager { private List balance; private android.content.Context context; - public HitBtcManager(android.content.Context context, String publicKey, String privateKey) + public HitBtcManager(android.content.Context context, Exchange exchange) { + super(exchange.id, exchange.name, exchange.type, exchange.description, exchange.publicKey, exchange.privateKey, exchange.isEnabled); + this.context = context; requestQueue = Volley.newRequestQueue(context); - - this.publicKey = publicKey; - this.privateKey = privateKey; } private void createPairSymbolList() diff --git a/app/src/main/java/com/herbron/moodl/LayoutManagers/CurrencyListAdapter.java b/app/src/main/java/com/herbron/moodl/LayoutManagers/CurrencyListAdapter.java index 8c2a134..cf18847 100644 --- a/app/src/main/java/com/herbron/moodl/LayoutManagers/CurrencyListAdapter.java +++ b/app/src/main/java/com/herbron/moodl/LayoutManagers/CurrencyListAdapter.java @@ -68,7 +68,7 @@ public class CurrencyListAdapter extends BaseAdapter implements Filterable { } if (position % 2 == 0) - convertView.setBackgroundColor(context.getResources().getColor(R.color.listBackground2)); + convertView.setBackgroundColor(context.getResources().getColor(R.color.white)); else convertView.setBackgroundColor(context.getResources().getColor(R.color.listBackground)); diff --git a/app/src/main/java/com/herbron/moodl/LayoutManagers/ExchangeListAdapter.java b/app/src/main/java/com/herbron/moodl/LayoutManagers/ExchangeListAdapter.java index 5c7bfe3..75759c5 100644 --- a/app/src/main/java/com/herbron/moodl/LayoutManagers/ExchangeListAdapter.java +++ b/app/src/main/java/com/herbron/moodl/LayoutManagers/ExchangeListAdapter.java @@ -1,6 +1,7 @@ package com.herbron.moodl.LayoutManagers; import android.content.Context; +import android.content.Intent; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.LayoutInflater; @@ -12,9 +13,13 @@ import android.widget.Filter; import android.widget.Filterable; import android.widget.TextView; +import com.herbron.moodl.Activities.AddExchangeActivity; +import com.herbron.moodl.Activities.ExchangeListActivity; import com.herbron.moodl.DataManagers.CurrencyData.Currency; import com.herbron.moodl.DataManagers.CurrencyData.Trade; +import com.herbron.moodl.DataManagers.DatabaseManager; import com.herbron.moodl.DataManagers.ExchangeManager.Exchange; +import com.herbron.moodl.MoodlBox; import com.herbron.moodl.R; import java.util.ArrayList; @@ -28,6 +33,7 @@ public class ExchangeListAdapter extends ArrayAdapter { public ExchangeListAdapter(Context context, ArrayList exchanges) { super(context, android.R.layout.simple_list_item_1, exchanges); + this.context = context; } @@ -41,12 +47,38 @@ public class ExchangeListAdapter extends ArrayAdapter { convertView = LayoutInflater.from(getContext()).inflate(R.layout.exchange_cell, parent, false); } + final View finalConvertView = convertView; + TextView exchangeNameTextView = convertView.findViewById(R.id.exchange_name); TextView exchangeDescriptionTextView = convertView.findViewById(R.id.exchange_description); exchangeNameTextView.setText(exchange.getName()); exchangeDescriptionTextView.setText(exchange.getDescription()); + if(!exchange.isEnabled()) + { + convertView.findViewById(R.id.exchange_account_off_imageView).setVisibility(View.VISIBLE); + } + + convertView.findViewById(R.id.editExchangeInfosLayout).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent editExchangeAccountIntent = new Intent(context, AddExchangeActivity.class); + editExchangeAccountIntent.putExtra("isEdit", true); + editExchangeAccountIntent.putExtra("exchangeId", exchange.getId()); + context.startActivity(editExchangeAccountIntent); + } + }); + + convertView.findViewById(R.id.deleteExchangeInfosLayout).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + DatabaseManager databaseManager = new DatabaseManager(getContext()); + databaseManager.deleteExchangeAccountFromId(exchange.getId()); + MoodlBox.collapseH(finalConvertView); + } + }); + return convertView; } diff --git a/app/src/main/res/drawable/ic_add_white_24dp.xml b/app/src/main/res/drawable/ic_add_white_24dp.xml new file mode 100644 index 0000000..e3979cd --- /dev/null +++ b/app/src/main/res/drawable/ic_add_white_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_arrow_drop_down_white_24dp.xml b/app/src/main/res/drawable/ic_arrow_drop_down_white_24dp.xml new file mode 100644 index 0000000..65e1e42 --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_drop_down_white_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_money_off_24dp.xml b/app/src/main/res/drawable/ic_money_off_24dp.xml new file mode 100644 index 0000000..ebcd2f4 --- /dev/null +++ b/app/src/main/res/drawable/ic_money_off_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/spinner_background.xml b/app/src/main/res/drawable/spinner_background.xml new file mode 100644 index 0000000..66a69c8 --- /dev/null +++ b/app/src/main/res/drawable/spinner_background.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_add_exchange.xml b/app/src/main/res/layout/activity_add_exchange.xml new file mode 100644 index 0000000..b0e956c --- /dev/null +++ b/app/src/main/res/layout/activity_add_exchange.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/binance_exchange_setup_layout.xml b/app/src/main/res/layout/binance_exchange_setup_layout.xml new file mode 100644 index 0000000..262b89d --- /dev/null +++ b/app/src/main/res/layout/binance_exchange_setup_layout.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/cardview_currency.xml b/app/src/main/res/layout/cardview_currency.xml index 6ff7032..0990113 100644 --- a/app/src/main/res/layout/cardview_currency.xml +++ b/app/src/main/res/layout/cardview_currency.xml @@ -40,7 +40,7 @@ android:layout_gravity="center_vertical" android:gravity="start" android:textColor="@color/mainTextViewColor" - android:textSize="@dimen/cardViewMainText" /> + android:textSize="@dimen/cardViewTitle" /> + android:textSize="@dimen/cardViewCaption" /> + android:textSize="@dimen/cardViewTitle" /> @@ -73,7 +73,7 @@ android:layout_height="wrap_content" android:gravity="start" android:textColor="@color/secondaryTextViewColor" - android:textSize="@dimen/cardViewMainText" + android:textSize="@dimen/cardViewTitle" android:visibility="gone"/> + android:textSize="@dimen/cardViewTitle" /> + android:textSize="@dimen/cardViewCaption" /> @@ -112,13 +112,13 @@ android:id="@+id/currencyFluctuationPercentageTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textSize="@dimen/cardViewMainText" /> + android:textSize="@dimen/cardViewTitle" /> + android:textSize="@dimen/cardViewCaption" /> @@ -143,7 +143,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/day_history" - android:textSize="@dimen/cardViewSecondaryText" /> + android:textSize="@dimen/cardViewCaption" /> + android:textSize="@dimen/cardViewTitle" /> + android:textSize="@dimen/cardViewCaption" /> @@ -86,7 +86,7 @@ android:layout_height="wrap_content" android:gravity="start" android:textColor="@color/secondaryTextViewColor" - android:textSize="@dimen/cardViewMainText" + android:textSize="@dimen/cardViewTitle" android:layout_weight="0.5"/> + android:textSize="@dimen/cardViewTitle" /> + android:textSize="@dimen/cardViewCaption" /> @@ -154,7 +154,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/day_history" - android:textSize="@dimen/cardViewSecondaryText" /> + android:textSize="@dimen/cardViewCaption" /> - - - - - - + android:layout_height="50dp" + android:id="@+id/swipeLayout"> + + + - + + + + + + + + + + + + + + + android:orientation="horizontal"> - + - + - + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/exchange_spinner_item.xml b/app/src/main/res/layout/exchange_spinner_item.xml new file mode 100644 index 0000000..fe90b78 --- /dev/null +++ b/app/src/main/res/layout/exchange_spinner_item.xml @@ -0,0 +1,9 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/hitbtc_exchange_setup_layout.xml b/app/src/main/res/layout/hitbtc_exchange_setup_layout.xml new file mode 100644 index 0000000..262b89d --- /dev/null +++ b/app/src/main/res/layout/hitbtc_exchange_setup_layout.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 38951af..51f5703 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -139,4 +139,5 @@ Supprimer les entrées manuelles actuelles Supprimer la liste suivie actuelle Supprimer les clefs API actuelles + Choose an exchange \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml new file mode 100644 index 0000000..c37eb98 --- /dev/null +++ b/app/src/main/res/values/arrays.xml @@ -0,0 +1,7 @@ + + + + Binance + HitBTC + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 3012892..0454a96 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -28,7 +28,6 @@ #FFED143D #FF00E000 #FFEEEEEE - #FFFFFFFF #66999999 #FFF44336 #FF4CAF50 @@ -41,4 +40,8 @@ #FF689afe #22689afe #FFAAAAAA + #FF898989 + #66FFFFFF + + #FFF5BC00 \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 61b39ec..9144acb 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,6 +1,6 @@ - 15sp - 12sp + 16sp + 12sp 150dp 172dp @@ -15,4 +15,5 @@ 8dp 15dp + 16dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c479a64..2f96301 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -249,5 +249,12 @@ Wipe current entries Wipe current watchlist Wipe current API keys + ExchangeList + Choose an exchange + Account label + Public key + API Key + Secret Key + Informations diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 592b287..12c6d3a 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -10,7 +10,7 @@ @color/decrease -