From a64aed47292f0cb4b15216ce0722bbb3b96f46d9 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Tue, 31 Jul 2018 13:16:42 +0200 Subject: [PATCH] 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">